package main;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.renderer.lwjgl.render.LwjglRenderDevice;
import de.lessvoid.nifty.sound.openal.OpenALSoundDevice;
import de.lessvoid.nifty.spi.time.impl.AccurateTimeProvider;


public class Launch { 
	private Launch() {
	  }

	  public static void main(final String[] args) {
	    initLwjgl();
	    render(createAndDisplayMenu());
	  }

	  private static void initLwjgl() {
	    if (!LwjglInitHelper.initSubSystems("Basic 1.0")) {
	      System.exit(0);
	    }
	  }

	  private static Nifty createAndDisplayMenu() {
	    Nifty nifty = new Nifty(
	        new LwjglRenderDevice(),
	        new OpenALSoundDevice(),
	        LwjglInitHelper.getInputSystem(),
	        new AccurateTimeProvider());
	    nifty.fromXml("layouts/home.xml", "start"); //the first screen must be called "start"
	    return nifty;
	  }

	  private static void render(final Nifty nifty) {
	    LwjglInitHelper.renderLoop(nifty, null);
	    LwjglInitHelper.destroy();
	  }
} 